﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Common;
using BusinessLayer;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;

namespace SeAssignment.Models
{
    public class RegisterModel
    {
        [Required(ErrorMessage = "Username is required")]
        [Remote("DoesUsernameExists", "User", ErrorMessage = "Username already registered!")]
        public string Username { get; set; }

        [Required(ErrorMessage = "Password is required")]
        public string Password { get; set; }

        [Required(ErrorMessage = "Email is required")]
        [DataType(DataType.EmailAddress, ErrorMessage = "Incorrect Email format!")]
        [RegularExpression(@"[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}", ErrorMessage = "Please enter correct email!")]
        [Remote("DoesEmailExists", "User", ErrorMessage = "Email already registered!")]
        public string Email { get; set; }

        [Required(ErrorMessage = "Title is required")]
        public string Title { get; set; }

        [Required(ErrorMessage = "Name is required")]
        public string Name { get; set; }

        [Required(ErrorMessage = "Surname is required")]
        public string Surname { get; set; }

        [Required(ErrorMessage = "DOb is required")]
        public DateTime DOB { get; set; }

        [Required(ErrorMessage = "Gender is required")]
        public SelectList Gender { get; set; }

        [Required(ErrorMessage = "Telephone is required")]
        public int Telephone { get; set; }

        [Required(ErrorMessage = "Mobile No is required")]
        public int MobileNo { get; set; }

        [Required(ErrorMessage = "House Number is required")]
        public int HouseNo { get; set; }

        [Required(ErrorMessage = "Street Name is required")]
        public string StreetName { get; set; }

        [Required(ErrorMessage = "Town is required")]
        public string Town { get; set; }

        [Required(ErrorMessage = "Country is required")]
        public int Country { get; set; }

        public SelectList TownList { get; set; }
        public SelectList CountryList { get; set; }
        public SelectList AccountType { get; set; }

        public RegisterModel()
        {
            TownList = new SelectList(new UsersBL().GetCountries(), "ID", "TownName");
            CountryList = new SelectList(new UsersBL().GetCountries(), "ID", "CountryName");
            AccountType = new SelectList(new[]{ new{ID="1",Name="Buyer"}, new{ID="2",Name="Seller"}});
            Gender = new SelectList(new[] { new { ID = "1", Name = "Male" }, new { ID = "2", Name = "Female" } });
        }
    }
}